import { Component, OnInit } from "@angular/core";
import { _HttpClient } from "@delon/theme";
import { G2TimelineData } from "@delon/chart";
import { DeviceInspectionTaskService } from "../device/device-inspection-task/device-inspection-task.service";
import { DeviceMaintainTaskService } from "../device/device-maintain-task/device-maintain-task.service";

@Component({
  selector: "app-dashboard",
  templateUrl: "./dashboard.component.html"
})
export class DashboardComponent implements OnInit {

  // 巡检任务数
  deviceInspectionTask = '0';
  // 保养任务数
  deviceMaintainTask= '0';

  chartData: G2TimelineData[] = [];

  constructor(private http: _HttpClient,
              private deviceInspectionTaskService: DeviceInspectionTaskService,
              private deviceMaintainTaskService: DeviceMaintainTaskService
  ) {
  }

  ngOnInit() {

    // 巡检任务数
    this.deviceInspectionTaskService.getMonthTask().subscribe(res => {
      this.deviceInspectionTask = res.data;
    });
    // 保养任务数
    this.deviceMaintainTaskService.getMonthTask().subscribe(res => {
      this.deviceMaintainTask = res.data;
    });
    // 我的任务数量
    // 折线图数据
    for (let i = 0; i < 20; i += 1) {
      this.chartData.push({
        time: new Date().getTime() + 1000 * 60 * 30 * i,
        y1: Math.floor(Math.random() * 100) + 1000,
        y2: Math.floor(Math.random() * 100) + 10
      });
    }
  }

}
